package com.ouc.openplatform.zykt.standardManage.service.impl;

import java.util.List;

import com.ouc.openplatform.zykt.standardManage.dao.NJ_TestItemTempletDAO;
import com.ouc.openplatform.zykt.standardManage.model.NJ_TestItemTemplet;
import com.ouc.openplatform.zykt.standardManage.service.NJ_TestItemTempletService;



public class NJ_TestItemTempletServiceImpl implements NJ_TestItemTempletService {

	NJ_TestItemTempletDAO testItemTempletDAO;

	public NJ_TestItemTempletDAO getTestItemTempletDAO() {

		return testItemTempletDAO;
	}

	public void setTestItemTempletDAO(NJ_TestItemTempletDAO testItempletDAO) {
		this.testItemTempletDAO = testItempletDAO;
	}

	@Override
	public List<NJ_TestItemTemplet> searchAllTestItem(int testStandardID,
			String itemName, int startIndex, int endIndex) {

		return testItemTempletDAO.searchAllTestItem(testStandardID, itemName,
				startIndex, endIndex);
	}

	@Override
	public int insertTestItem(NJ_TestItemTemplet testItemTemplet) {
		int result = 0;
		int tmp = checkName(testItemTemplet);

		if (tmp == 0) {
			result = testItemTempletDAO.insertTestItem(testItemTemplet);
		}
		if (tmp != 0) {
			result = 7;
		}
		System.out.println("result:" + result);
		System.out.println("tmp:" + tmp);

		return result;
	}

	@Override
	public int deleteTestItem(int item_id) {

		return testItemTempletDAO.deleteTestItem(item_id);
	}

	@Override
	public int editTestItem(NJ_TestItemTemplet tit) {

		System.out.println("biz修改");
		System.out.println(tit.getItem_id() + tit.getItem_name());
		updateTestStandardSubiterm(tit.getItem_id(), tit.getItem_name());
		return testItemTempletDAO.editTestItem(tit);
	}

	@Override
	public NJ_TestItemTemplet searchTestItemByID(int id) {

		return testItemTempletDAO.searchTestItemByID(id);
	}

	@Override
	public int getSearchAllTestItemCount(int testStandardID, String itemName) {

		return testItemTempletDAO.getSearchAllTestItemCount(testStandardID,
				itemName);
	}

	@Override
	public int updateTestStandardSubiterm(int itID, String itName) {
		// TODO Auto-generated method stub
		return testItemTempletDAO.updateTestStandardSubiterm(itID, itName);
	}

	@Override
	public List<NJ_TestItemTemplet> getAllTestItem() {
		// TODO Auto-generated method stub
		return testItemTempletDAO.getAllTestItem();
	}

	@Override
	public List<NJ_TestItemTemplet> getAllTestItemByTstId(int tstId) {
		// TODO Auto-generated method stub
		System.out.println("biz-tstId:" + tstId);
		return testItemTempletDAO.getAllTestItemByTstId(tstId);
	}

	@Override
	public int checkName(NJ_TestItemTemplet testItemTemplet) {

		return testItemTempletDAO.checkName(testItemTemplet);
	}

	@Override
	public int getTstidByName(String name) {
		System.out.println("biz name="+name);
		return testItemTempletDAO.getTstidByName(name);
	}

	@Override
	public String getUsernoByName(String name) {
		
		return testItemTempletDAO.getUsernoByName(name);
	}

	@Override
	public int importByExcel(NJ_TestItemTemplet testItemTemplet) {
		System.out.println("biz TestItemTemplet 导入excel：");
		return testItemTempletDAO.importByExcel(testItemTemplet);
	}

	
}
